package cn.yunhe.control;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yunhe.entity.Blank;
import cn.yunhe.server.BlankServer;


@WebServlet("/DeleteBlankServlet")
public class DeleteBlankServlet extends HttpServlet{
	BlankServer bServer = new BlankServer();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String bName = request.getParameter("bName"); //获取要删除的板块名
		Blank blank = new Blank(bName);
		boolean flag = bServer.deletBlank(blank); //定义变量接收删除结果
		if (flag) {
			request.setAttribute("result", "删除成功!!");
			request.getRequestDispatcher("deleteBlank.jsp").forward(request, response); //跳转到原页面
		}else {
			request.setAttribute("result", "删除失败,请检查板块名称是否正确!!");
			request.getRequestDispatcher("deleteBlank.jsp").forward(request, response); //跳转到原页面
		}
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
}
